<html>
<head><meta charset="utf-8"><title>Async fn desugaring discussion? · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html">Async fn desugaring discussion?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163650308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163650308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> magnet <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163650308">(Apr 18 2019 at 13:18)</a>:</h4>
<p>Hey, apologies if this makes no sense (I'm not a contributor to Rustc) or if this has been discussed to death before.</p>
<p>Are there still any talks about async fn desugaring? We have been using async/await for about 6 months and it's great, but when discussing it I keep meeting people who struggle using it in no_std/environments lacking TLS. It feels weird that a language construct requires finding the Context/Waker from <em>somewhere</em> (i.e, a global variable, even if it's in TLS) and looks somewhat "unrusty".<br>
Is there any way async fns could be stabilized <em>without</em> getting into a place where global/TLS Context must be supported forever?</p>
<p>Random musings: currently, async fns are sugared/colored "enough" that no one directly calls them without a framework/mediator (e.g, the await! macro). I don't think it would be problematic to most users to desugar <code>async fn foo(bar: Bar) {}</code> to <code>fn foo(ctx: &amp;mut Context, bar: Bar) -&gt; XXX {}</code>, but<code>await</code> would have to be parameterized implictly? <em>and</em> there are no implicit parameters in Rust (or something similar, yet)... Could that implicit parameter thing be behind another feature gate, just like generators are, and we'd have async and await stabilized without committing to TLS?</p>



<a name="163658824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163658824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163658824">(Apr 18 2019 at 14:54)</a>:</h4>
<p><span class="user-mention" data-user-id="200746">@magnet</span> TLS is not a fundamental requirement of the design. It's usage in async/await will be removed when generators can take arguments.</p>



<a name="163658847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163658847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163658847">(Apr 18 2019 at 14:54)</a>:</h4>
<p>(or when we make a special tailored hack for it)</p>



<a name="163661376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163661376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> magnet <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163661376">(Apr 18 2019 at 15:20)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> but how can you stabilize async fns without stabilizing the desugaring or the exact behavior of generators?</p>



<a name="163661520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163661520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> magnet <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163661520">(Apr 18 2019 at 15:22)</a>:</h4>
<p>My understanding is that if <code>async fn</code> becomes stable and people start depending on how it is implemented, it will prevent alternative approaches to pass the context</p>



<a name="163661705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163661705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> magnet <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163661705">(Apr 18 2019 at 15:24)</a>:</h4>
<p>(I do understand how generators with arguments can solve this, but wouldn't changing that after async stabilization be a problem?)</p>



<a name="163664344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163664344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163664344">(Apr 18 2019 at 15:57)</a>:</h4>
<p><span class="user-mention" data-user-id="200746">@magnet</span> no, the stabilization does not include any aspect of generators nor the desugaring</p>



<a name="163675829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Async%20fn%20desugaring%20discussion%3F/near/163675829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> magnet <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Async.20fn.20desugaring.20discussion.3F.html#163675829">(Apr 18 2019 at 18:11)</a>:</h4>
<p>Alright, I see, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>